package com.hspedu.homework.homework11;

/**
 * 现有Person类，里面有方run eat, Student类继承了Person类，并重写了run方法，
 * 自定义了study方法，试着写出对象向上转型和向下转型的代码，
 * 并写出各自可以调用哪些方法，写出方法输出什么
 */
public class Homework11 {
    public static void main(String[] args) {
        Person student = new Student();//向上转型
        student.eat();
        student.run();
        Student student1 = (Student) student;//向下转型
        student1.study();
        student1.run();
        student1.eat();
    }
}

class Person {
    public void run(){
        System.out.println("person run");
    }
    public void eat(){
        System.out.println("person eat");
    }
}
class Student extends Person{
    public void run(){
        System.out.println("student run");
    }
    public void study(){
        System.out.println("student study......");
    }
}